<?php
class PNModelArray extends PNObjectExArray {
  function PNModelArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'innoforum_model';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';

    $this->_objJoin[]     = array ( 'join_table'  =>  'innoforum_brand',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('brand_name'),
                            'compare_field_table' =>  'brand_id',
                            'compare_field_join'  =>  'id');

    $this->_init($init, $where);
  }


  function genSort(){
    return " ORDER BY brand_name, name ASC";
  }


  function selectExtendResult(){
 
    $this->_objData;
    $result = array();
    $joinInfo[]     = array ( 'join_table'  =>  'innoforum_category',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('category_name'),
                            'compare_field_table' =>  'category_id',
                            'compare_field_join'  =>  'id');

    $joinInfo[]     = array ( 'join_table'  =>  'innoforum_subcategory',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('subcategory_name'),
                            'compare_field_table' =>  'subcategory_id',
                            'compare_field_join'  =>  'id');

    foreach($this->_objData as $key=>$item){
        $result['subcategory_model'][] = DBUtil::selectExpandedObjectArray('innoforum_subcategory_model', $joinInfo, "smod_model_id = ".$item[id], 'category_name, subcategory_name');
    }
    return $result;
  }

}